package com.sec.etech.employeesync.sapquery.strategy;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sec.etech.employeesync.sapquery.util.SapParamsBuilder;

import java.util.ArrayList;
import java.util.List;

public class CompanyQueryStrategy implements QueryStrategy {
    @Override
    public List<JSONObject> buildSapParams(JSONObject businessParams) {
        List<JSONObject> sapParamsList = new ArrayList<>();
        JSONArray code = businessParams.getJSONArray("code");

        for (int i = 0; i < code.size(); i++) {
            JSONObject sapParams = new JSONObject();
            sapParams.put("IT_DATUM", SapParamsBuilder.buildItDatum());
            sapParams.put("I_WERKS", code.getString(i));
            sapParamsList.add(sapParams);
        }

        return sapParamsList;
    }
}
